<template>
  <div class="content">
    <van-cell
      value=""
      v-for="(item, index) in items"
      :key="index"
      class="item"
      is-link
      @click="getinfoAction(item)"
    >
      <!-- 使用 title 插槽来自定义标题 -->
      <template #title>
        <span class="custom-title">{{ item }}</span>
      </template>
    </van-cell>
  </div>
</template>

<script>
import { Cell } from "vant";
export default {
  components: {
    [Cell.name]: Cell,
  },
  props: {
    id: Number,
  },
  data() {
    return {
      items: [],
      list1: [
        "心内科",
        "消化内科",
        "感染内科",
        "风湿免疫内科",
        "内分泌科",
        "皮肤科",
        "中医科",
        "临床营养科",
        "康复医学科",
      ],
      list2: [
        "基本外科",
        "骨科",
        "心外科",
        "胸外科",
        "泌尿外科",
        "乳腺外科",
        "口腔科",
        "肝脏外科",
        "麻醉科",
        "妇产科",
        "眼科",
      ],
      list3: ["超声科", "病理科", "检验科", "放射科", "输血科", "病案科"],
    };
  },
  methods: {
    getinfoAction(item) {
      console.log(item);
    },
  },
  created() {
    this.items = this.list1;
  },
  watch: {
    id() {
      if (this.id == 0) {
        this.items = this.list1;
      } else if (this.id == 1) {
        this.items = this.list2;
      } else {
        this.items = this.list3;
      }
    },
  },
};
</script>

<style scoped lang="scss">
@function vw($px) {
  @return ($px/375) * 100vw;
}
* {
  margin: 0;
  padding: 0;
}
.content {
  position: absolute;
  top: vw(95);
  z-index: 1;
  width: 100%;
}
.item {
  width: 100%;
  height: vw(42);
  font-size: vw(24) !important;
  display: flex;
  align-items: center;
  padding-left: vw(10);
  span {
    font-size: vw(15) !important;
    margin-left: vw(5);
  }
  .van-icon {
    margin-right: vw(10);
  }
  .van-cell__title {
    display: flex;
    align-items: center;
  }
}
</style>